@extends('master')
@section('title', $categ->nombre)
@section('content')

<div id="infinitescroll" class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <h3>{{ $categ->nombre }}</h3>
        </div>
    </div>

    {{--------------------------------- Lista de Relatos --------------------------------}}
    @foreach($relatos as $relato)
    <div class="caja">
        <div class="row">
            <div class="col-md-6">
                @if( $image = $relato->getFirstImage() )
                    <a href="{{ URL::route('relato', ['slug' => $relato->slug, 'id' => $relato->id]) }}">
                        <img class="lazy img-full" src="{{ $src = URL::to($image->img->url('rel_list')) }}" data-original="{{ $src }}" alt="{{ $image->title }}"/>
                    </a>
                @endif
            </div>
            <div class="col-md-6">
                <h2><a href="{{ URL::route('relato', ['slug' => $relato->slug, 'id' => $relato->id]) }}">{{ $relato->titulo }}</a></h2>
                <p>&#8212;<br>{{ $relato->bajada }}</p>
            </div>
        </div>
        <br>
    </div>
    
    @endforeach
    {{------------------------------- FIN Lista de Relatos -------------------------------}}
    {{  $relatos->links() }}
</div>
@stop

@section('scripts')
    {{ HTML::script('assets/js/infinitescroll.js') }}
    <script>
        $('#infinitescroll').infinitescroll({
            navSelector     : ".pager",
            nextSelector    : ".pager a:last",
            itemSelector    : ".caja",
            debug           : false,
            dataType        : 'html',
            maxPage: {{ $lastPage }},
            path: function(index) {
                return "?page=" + index;
            },
            loading: {
                finishedMsg: "",
                img: "{{ URL::to('assets/img/preloader.gif') }}",
                msgText: ""
            }
        });
    </script>
@stop